global_defs {
    router_id {{ ansible_hostname }}
}

vrrp_instance VI_1 {

{% if ansible_hostname == "lvs-master" %}
    state MASTER
    priority 200
{%elif ansible_hostname == "lvs-slave" %}
    state BACKUP
    priority 150
{% endif %}

    interface eth1
    virtual_router_id 50
    advert_int 3
    authentication {
        auth_type PASS
        auth_pass 1111
 }
    virtual_ipaddress {
        {{ cluster_vip }}
    }
}

# 配置集群地址访问的IP+Port
virtual_server {{ cluster_vip }} {{ cluster_port }} {
    delay_loop 6
    lb_algo wlc
    lb_kind DR
    perssisstence_timeout 5
    protocol TCP

{% for realserver_ip in groups["lbservers"]%}
    real_server {{ realserver_ip }} {{ realserver_port }} {
        weight 1
        TCP_CHECK {
            connect_port {{ realserver_port }}
            connect_timeout 3
            nb_get_retry 2
            delay_beefore_retry 3
        }
    }
{% endfor %}

}
